package com.kaifamiao.list;

import java.util.ArrayList;
import java.util.List;

/**
 * 1、of
 * 2、copyOf
 */
public class ListStaticMethods {

    public static void main(String[] args) {
        List emptyList = List.of();
        System.out.println( emptyList.isEmpty() );

        List<String> names = List.of( "孙悟空", "猪悟能" , "沙悟净" );
        System.out.println( names );

        // names.add( "唐三藏" ); // java.lang.UnsupportedOperationException
        // names.remove( 1 ); // java.lang.UnsupportedOperationException
        // names.set( 0 , "唐三藏" ); // java.lang.UnsupportedOperationException
        // names.sort( null ); // java.lang.UnsupportedOperationException

        List<String> nameList = new ArrayList<>();
        nameList.addAll( names );
        nameList.add( 0, "唐三藏" );
        System.out.println( nameList );

        List<String> another = List.copyOf( nameList );
        System.out.println( another );

    }

}
